package com.fantasy.csm.util;

import java.sql.SQLException;
import java.util.List;

import com.fantasy.mysql.SqlRowValue;
import com.fantasy.mysql.SqlUtil;
import com.fantasy.string.FormatUtils;

public class DeleteRepeat {

	public static void delete() {
		SqlUtil sU = new SqlUtil();

		try {
			List<SqlRowValue> vL = sU.getResult("select * from ws_mstr");

			for (SqlRowValue sqlRowValue : vL) {
				String wsIp = sqlRowValue.getValue("ws_ip");
				String wsName = sqlRowValue.getValue("ws_name");
				for (SqlRowValue sqlRowValue1 : vL) {
					if (wsIp.equals(sqlRowValue1.getValue("ws_ip"))) {
						if (!wsName.equals(sqlRowValue1.getValue("ws_name")) && !"".equals(sqlRowValue1.getValue("ws_ip"))) {
							if (FormatUtils.string2Date(sqlRowValue1.getValue("ws_auditdate"), FormatUtils.DATE_TYPE)
									.getTime() > FormatUtils
											.string2Date(sqlRowValue.getValue("ws_auditdate"), FormatUtils.DATE_TYPE)
											.getTime()) {
								System.out.println(sqlRowValue.getValue("ws_name"));
								System.out.println(sqlRowValue1.getValue("ws_auditdate") + ">>>>"
										+ sqlRowValue.getValue("ws_auditdate"));
								sU.delete(sqlRowValue, "ws_mstr" , "ws_name");
							} else {
								System.out.println(sqlRowValue1.getValue("ws_name"));
								System.out.println(sqlRowValue.getValue("ws_auditdate") + ">>>>"
										+ sqlRowValue1.getValue("ws_auditdate"));
								sU.delete(sqlRowValue1, "ws_mstr" , "ws_name");
							}
						}
					}
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		DeleteRepeat.delete();
	}
}
